#!/usr/bin/python

import re



def find():
	a = '[START:hello]asd`\nworld.\n[END:hello]\nthis is from jvm\n[START:c1]\nasdasd\n[END:c1]\n'

#	find pair
#	p = re.compile(r'\[START:(?P<label>[^:]*)\](.*)\[END:(?P=label)\]', re.DOTALL)
#	find mid
#	p = re.compile(r'\[[^:]*:[^:]*\]*(.*)\[[^:]*:[^:]*\]*', re.DOTALL)
	p = re.compile(r'(?P<log>\[[^:]*:[^:]*\])', re.DOTALL)

	m = p.findall(a)

	print(a)

	if m:
		print(m)
	else:
		print('not matched.')

	s = re.sub(r'(?P<log>\[[^:]*:[^:]*\])', '', a).rstrip()

	print(s)

	s = '     \n'
	s = s.rstrip()
	if(s):
		print('something.')
		print('#', s, '#')
	else:
		print('nothing')

def findMid():
	a = '[START:hello]asd`\nworld.\n[END:hello]\n[START:c1]\nasdasd\n[END:c1]\n'
	p = re.compile(r'\[START:(?P<label>[^:]*)\](.*)\[END:(?P=label)\]', re.DOTALL)
	
	m = p.findall(a)
	print(a)

def main():
	find()

if __name__ == '__main__':
	main()
					
